package com.example.service;


import com.example.index.Book;
import com.example.repository.BookRepository;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class BookService {

    @Resource
    BookRepository bookRepository;


    public void saveBook(Book book) {
        bookRepository.save(book);
    }

    public void findAll() {
        bookRepository.findAll().forEach(System.out::println);
    }

    public void findByBookName(String bookName) {
        bookRepository.findByBookName(bookName).forEach(System.out::println);
    }

    public void updateBook(Book book) {
        bookRepository.save(book);
    }

    public void deteleById(Long id){
        bookRepository.deleteById(id);
    }


}
